using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JGSY.CMS.LowCode.Platform.Domain.Entities;

namespace JGSY.CMS.LowCode.Platform.Domain.Interfaces
{
    /// <summary>
    /// 分类仓储接口
    /// 提供分类实体的专业化数据访问操作，包括层级结构管理、路径查询、类型筛选等功能
    /// 支持分类的树形结构操作，包括获取子分类、后代分类、路径查询等业务场景
    /// </summary>
    public interface ICategoryRepository : IRepository<Category>
    {
        /// <summary>
        /// 根据类型获取分类列表
        /// </summary>
        /// <param name="type">分类类型</param>
        /// <returns>分类列表</returns>
        Task<List<Category>> GetByTypeAsync(string type);
        
        /// <summary>
        /// 根据父分类ID获取子分类列表
        /// </summary>
        /// <param name="parentId">父分类ID</param>
        /// <param name="includeDisabled">是否包含禁用的分类</param>
        /// <returns>子分类列表</returns>
        Task<List<Category>> GetChildrenAsync(long parentId, bool includeDisabled = false);
        
        /// <summary>
        /// 根据路径获取分类
        /// </summary>
        /// <param name="path">分类路径</param>
        /// <returns>分类实体</returns>
        Task<Category?> GetByPathAsync(string path);
        
        /// <summary>
        /// 检查分类名称是否存在
        /// </summary>
        /// <param name="name">分类名称</param>
        /// <param name="type">分类类型</param>
        /// <param name="parentId">父分类ID</param>
        /// <param name="excludeId">排除的分类ID</param>
        /// <returns>是否存在</returns>
        Task<bool> ExistsAsync(string name, string type, long? parentId = null, long? excludeId = null);
        
        /// <summary>
        /// 获取分类的所有后代
        /// </summary>
        /// <param name="categoryId">分类ID</param>
        /// <returns>后代分类列表</returns>
        Task<List<Category>> GetDescendantsAsync(long categoryId);
        
        /// <summary>
        /// 获取分类的所有祖先
        /// </summary>
        /// <param name="categoryId">分类ID</param>
        /// <returns>祖先分类列表</returns>
        Task<List<Category>> GetAncestorsAsync(long categoryId);
        
        /// <summary>
        /// 获取树形结构的分类列表
        /// </summary>
        /// <param name="type">分类类型</param>
        /// <param name="parentId">父分类ID</param>
        /// <returns>树形分类列表</returns>
        Task<List<Category>> GetTreeAsync(string? type = null, long? parentId = null);
    }
}
